package com.mypackage.diary.model;

// Generated Nov 7, 2014 12:02:55 AM by Hibernate Tools 3.4.0.CR1

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Diary generated by hbm2java
 */
@Entity
@Table(name = "diary", catalog = "diary")
public class Diary implements java.io.Serializable {

	private Integer idDiary;
	private Userprofile userprofile;
	private String title;
	private String body;
	private String excerpt;
	private Boolean isCommentClosed;
	private Integer privacy;
	private Date created;
	private Date modified;
	private Set<Category> categories = new HashSet<Category>(0);
	private Set<Diarypermission> diarypermissions = new HashSet<Diarypermission>(
			0);
	private Set<Comment> comments = new HashSet<Comment>(0);

	public Diary() {
	}

	public Diary(Userprofile userprofile) {
		this.userprofile = userprofile;
	}

	public Diary(Userprofile userprofile, String title, String body,
			String excerpt, Boolean isCommentClosed, Integer privacy,
			Date created, Date modified, Set<Category> categories,
			Set<Diarypermission> diarypermissions, Set<Comment> comments) {
		this.userprofile = userprofile;
		this.title = title;
		this.body = body;
		this.excerpt = excerpt;
		this.isCommentClosed = isCommentClosed;
		this.privacy = privacy;
		this.created = created;
		this.modified = modified;
		this.categories = categories;
		this.diarypermissions = diarypermissions;
		this.comments = comments;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "IdDiary", unique = true, nullable = false)
	public Integer getIdDiary() {
		return this.idDiary;
	}

	public void setIdDiary(Integer idDiary) {
		this.idDiary = idDiary;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "AuthorId", nullable = false)
	public Userprofile getUserprofile() {
		return this.userprofile;
	}

	public void setUserprofile(Userprofile userprofile) {
		this.userprofile = userprofile;
	}

	@Column(name = "Title")
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "Body")
	public String getBody() {
		return this.body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	@Column(name = "Excerpt", length = 512)
	public String getExcerpt() {
		return this.excerpt;
	}

	public void setExcerpt(String excerpt) {
		this.excerpt = excerpt;
	}

	@Column(name = "IsCommentClosed")
	public Boolean getIsCommentClosed() {
		return this.isCommentClosed;
	}

	public void setIsCommentClosed(Boolean isCommentClosed) {
		this.isCommentClosed = isCommentClosed;
	}

	@Column(name = "Privacy")
	public Integer getPrivacy() {
		return this.privacy;
	}

	public void setPrivacy(Integer privacy) {
		this.privacy = privacy;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "Created", length = 19)
	public Date getCreated() {
		return this.created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "Modified", length = 19)
	public Date getModified() {
		return this.modified;
	}

	public void setModified(Date modified) {
		this.modified = modified;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "diaryincategory", catalog = "diary", joinColumns = { @JoinColumn(name = "DiaryId", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "CategoryId", nullable = false, updatable = false) })
	public Set<Category> getCategories() {
		return this.categories;
	}

	public void setCategories(Set<Category> categories) {
		this.categories = categories;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "diary")
	public Set<Diarypermission> getDiarypermissions() {
		return this.diarypermissions;
	}

	public void setDiarypermissions(Set<Diarypermission> diarypermissions) {
		this.diarypermissions = diarypermissions;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "diary")
	public Set<Comment> getComments() {
		return this.comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}

}
